package com.lykj.modules.job.config;

import com.lykj.job.core.executor.impl.LykjJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * lykj-job config
 *
 * @author cxl 2017-04-28
 */
//@Configuration
public class LykjJobConfig {
	private Logger logger = LoggerFactory.getLogger(LykjJobConfig.class);

	@Value("${lykj.job.admin.addresses}")
	private String adminAddresses;

	@Value("${lykj.job.accessToken}")
	private String accessToken;

	@Value("${lykj.job.executor.appname}")
	private String appname;

	@Value("${lykj.job.executor.address}")
	private String address;

	@Value("${lykj.job.executor.ip}")
	private String ip;

	@Value("${lykj.job.executor.port}")
	private int port;

	@Value("${lykj.job.executor.logpath}")
	private String logPath;

	@Value("${lykj.job.executor.logretentiondays}")
	private int logRetentionDays;


//	@Bean
	public LykjJobSpringExecutor lykjJobExecutor() {
		logger.info(">>>>>>>>>>> lykj-job config init.");
		LykjJobSpringExecutor lykjJobSpringExecutor = new LykjJobSpringExecutor();
		lykjJobSpringExecutor.setAdminAddresses(adminAddresses);
		lykjJobSpringExecutor.setAppname(appname);
		lykjJobSpringExecutor.setAddress(address);
		lykjJobSpringExecutor.setIp(ip);
		lykjJobSpringExecutor.setPort(port);
		lykjJobSpringExecutor.setAccessToken(accessToken);
		lykjJobSpringExecutor.setLogPath(logPath);
		lykjJobSpringExecutor.setLogRetentionDays(logRetentionDays);

		return lykjJobSpringExecutor;
	}
}
